<?php
$pagename = '首页';
include 'header.php';
?>
		<div id="nav">
			<h1><a href="index.php">NDSOJ</a></h1>
			<ul>
				<li id="nav_current">首页</li>
				<?php if(!$_SESSION['login']) echo "<li><a href=\"reg.php\">注册</a></li>\n\t\t\t\t";
				?><li><a href="problem.php">题库</a></li>
				<li><a href="contest.php">比赛</a></li>
				<li><a href="discuss.php">讨论</a></li>
				<li><a href="help.php">帮助</a></li>
				<li><a href="about.php">关于</a></li>
			</ul>
		</div>
		<div id="mainbox">
			<h2>最新题目</h2>
			<ul>
			<?php
			require_once 'mysql_conn_3asY&AKj0qB1.php';
			$query = "SELECT id, name FROM problems ORDER BY id DESC LIMIT 5;";
			$result = @mysqli_query($NDSOJ_dbc, $query);
			if (!$result) {
				echo '呃，看起来出了点小问题…请尽快联系我们。我们的E-mail：hcc@shiyihcc.com';
				//echo mysqli_error($NDSOJ_dbc);
			}
			else {
				while($row = mysqli_fetch_array($result)) {
					echo '<li><a href="problem_show.php?id=' . $row['id'] . '">' . $row['name'] . '</a></li>';
				}
				mysqli_free_result($result);
			}
			?>
			</ul>
			<!--<h2>最新比赛</h2>
			<ul>
				<li><a href="contest_show.php">Xhacker邀请赛</a></li>
				<li><a href="contest_show.php">Penhu邀请赛</a></li>
			</ul>-->
			<h2>最新话题</h2>
			<ul>
				<li><a href="discuss_show.php">[公告] NDSOJ 12月14日更新情况</a></li>
				<li><a href="discuss_show.php">[公告] NDSOJ将于24日晚停机维护</a></li>
				<li><a href="discuss_show.php">这道题为什么超时？</a></li>
				<li><a href="discuss_show.php">赞一个！</a></li>
				<li><a href="discuss_show.php">最近有什么模拟赛吗？</a></li>
			</ul>
		</div>
		<div id="sidebar">
<?php include 'module_themeselector.php'; ?>
		<?php
		if($_SESSION['login']) {
			include 'module_userbox.php';
		} else {
			echo <<<LOGIN_FORM
			<h2>登录</h2>
			<form action="login.php" method="post">
				<p><label for="username">用户</label><input name="username" id="username" type="text" /></p>
				<p><label for="password">密码</label><input name="password" id="password" type="password" /></p>
				<p><button type="submit">登录</button>
				<button type="button" onclick="location.href='reg.php'">注册</button></p>
			</form>
LOGIN_FORM;
		}
		?>
<?php include 'module_jumpbox.php'; ?>
		</div>
<?php mysqli_close($NDSOJ_dbc); ?>
<?php include 'footer.php'; ?>
